<template>
  <div class="nav-group" :class="toggleFlag ? '' : 'smallNav'">
    <div>
      <p class="logo">{{toggleFlag ? '安全数据中心' : ''}}</p>
      <ul class="nav-list">
        <!--      <li @click="goPath('/home')" :class="$route.path == '/home' ? 'select' : ''">-->
        <!--        <i class="icon-nav_home"></i>-->
        <!--        首页-->
        <!--      </li>-->
        <li v-for="item in $store.getters.MENULIST" v-if="item.menuType == 1" @click="() => {goPath(item)}" :class="isSelect.indexOf(item.id) > -1 ? 'select' : ''">

          <template v-if="toggleFlag">
            <!--home-->
            <i class="icon-nav_home" v-if="item.menuPath == '/home'"></i>
            <!--数据采集-->
            <i class="icon-nav_caiji" v-else-if="item.menuPath == '/collectionData/dacManagement'"></i>
            <!--        数据预处理-->
            <i class="icon-nav_yuchuli" v-else-if="item.menuPath == '/dataPreprocessing/dataPreManagement/list'"></i>
            <!--        安全数据治理-->
            <i class="icon-nav_zhili" v-else-if="item.menuPath == '/dataGovernance/storeManagement'"></i>
            <!--       数据共享 -->
            <i class="icon-server_fill" v-else-if="item.menuPath == '/dataShare/platServiceManagement'"></i>
            <!--        系统管理-->
            <i class="icon-nav_xitong" v-else-if="item.menuPath == '/systemManagement/userManagement'"></i>
            <!--        监控管理-->
            <!--        <i class="icon-nav_jiankong" v-else-if="item.menuPath == '/systemManagement/userManagement'"></i>-->
            <!--        其他-->
            <i class="icon-nav_caiji" v-else></i>
          </template>

          <template v-else="toggleFlag">
            <a-tooltip placement="right" overlayClassName="nav-tip">
              <template slot="title" :style="{left: '40px'}">{{item.menuName}}</template>
              <!--home-->
              <i class="icon-nav_home" v-if="item.menuPath == '/home'"></i>
              <!--数据采集-->
              <i class="icon-nav_caiji" v-else-if="item.menuPath == '/collectionData/dacManagement'"></i>
              <!--        数据预处理-->
              <i class="icon-nav_yuchuli" v-else-if="item.menuPath == '/dataPreprocessing/dataPreManagement/list'"></i>
              <!--        安全数据治理-->
              <i class="icon-nav_zhili" v-else-if="item.menuPath == '/dataGovernance/storeManagement'"></i>
              <!--       数据共享 -->
              <i class="icon-server_fill" v-else-if="item.menuPath == '/dataShare/platServiceManagement'"></i>
              <!--        系统管理-->
              <i class="icon-nav_xitong" v-else-if="item.menuPath == '/systemManagement/userManagement'"></i>
              <!--        监控管理-->
              <!--        <i class="icon-nav_jiankong" v-else-if="item.menuPath == '/systemManagement/userManagement'"></i>-->
              <!--        其他-->
              <i class="icon-nav_caiji" v-else></i>
            </a-tooltip>
          </template>

          <span v-if="toggleFlag">
          {{item.menuName}}
        </span>
        </li>
      </ul>
      <div style="height: 180px"></div>
    </div>
    <div v-if="userType == '0'" class="home-link" :class="$store.getters.NAVTOGGLE ? '' :'toSmall'" @click="goIndexPage">
      <img src="../assets/components/nav/link-home-icon.png" alt="">
      <span>全景视图 <i class="icon-zhixiang_line"></i></span>
    </div>
    <a-tooltip placement="right" overlayClassName="nav-tip" v-show="!$store.getters.NAVTOGGLE">
      <template slot="title" :style="{left: '40px'}">全景视图</template>
      <div class="small-home-link" :class="!$store.getters.NAVTOGGLE ? 'toShowBig' : ''" @click="goIndexPage"> </div>
    </a-tooltip>
  </div>
</template>

<script>
import commonJS from '@/utils/commonJS'
export default {
  name: 'Nav',
  // props: ['navList', 'selectPage'],
  // watch:{
  //   '$store.getters.MENULIST':
  // },
  props: ['changePage'],
  data () {
    return {
      userType: this.$store.state.common.USERTYPE
    }
  },
  computed: {
    toggleFlag: function () {
      return this.$store.getters.NAVTOGGLE
    },
    isSelect: function (id) {
      // let flag = commonJS.menuIsSelect(this, path, 0)
      let selectIdList = commonJS.getParents(this)
      return selectIdList
    }
  },
  methods: {
    goIndexPage () {
      this.$router.push({path: '/homeBigScreen'})
    },
    goPath (item) {
      let path = commonJS.getNavJumpUrl(item)
      this.$emit('changePage', path)
      this.$router.push({path: path})
    },
    setIcon (path) {
      switch (path) {
        case '/systemManagement/userManagement':
          return (<i class="icon-nav_yuchuli"></i>)
      }
    }
  },
  created () {}
}

</script>

<style lang="less">
.nav-tip {
  left: 45px !important;
}
</style>

<style lang="less" scoped>
@keyframes toHide
{
  0% { display: block;opacity: 1 }
  10% { opacity: 1 }
  90% { opacity: 0}
  100% {opacity: 0; display: none;}
}

@-webkit-keyframes toHide /* Safari 与 Chrome */
{
  0% { display: block;opacity: 1 }
  10% { opacity: 1 }
  90% { opacity: 0}
  100% {opacity: 0; display: none;}
}

@keyframes toShow
{
  0% { display: block; opacity: 0 }
  10% { opacity: 0 }
  90% { opacity: 1}
  100% {display: block; opacity: 1}
}

@-webkit-keyframes toShow /* Safari 与 Chrome */
{
  0% { display: block; opacity: 0 }
  10% { opacity: 0 }
  90% { opacity: 1}
  100% {display: block; opacity: 1}
}

.nav-group {
  z-index: 99;
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  overflow: hidden;
  min-height: 100%;
  background: #2E3541;
  transition: All 0.3s ease-out;
  &.smallNav {
    width: 48px;
    overflow: hidden;
    .logo {
      margin-left: 7px;
    }
    .nav-list {
      li {
        i {
          left: 10px;
        }
      }
    }
  }
  .logo {
    margin: 10px 16px;
    height: 36px;
    width: 168px;
    padding-left: 46px;
    font-size: 18px;
    line-height: 36px;
    color: #FFFFFF;
    letter-spacing: 0;
    font-weight: bold;
    background: url("../assets/components/header/logo.png") 0px -1px no-repeat;
    background-size: 32px;
  }
  .nav-list {
    width: 200px;
    li {
      cursor: pointer;
      position: relative;
      height: 48px;
      padding-left: 44px;
      font-size: 14px;
      line-height: 48px;
      color: rgba(255,255,255,0.65);
      letter-spacing: 0;
      font-weight: 500;
      border-left: 4px solid transparent;
      i {
        position: absolute;
        left: 16px;
        font-size: 20px;
        line-height: 48px;
        color: rgba(255,255,255,0.65);
      }
      &.select {
        color: #ffffff;
        background: #333e50;
        border-left: 4px solid rgba(255,255,255,0.90);
        i {
          color: #ffffff ;
        }
      }
      &:hover {
        color: #ffffff;
        i {
          color: #ffffff ;
        }
      }

    }
  }
  .home-link {
    cursor: pointer;
    width: 160px;
    height: 90px;
    text-align: center;
    position: absolute;
    margin: auto;
    bottom: 48px;
    left: 20px;
    background: url("../assets/components/nav/link-home-bg.png") 50% 50% no-repeat;
    background-size: contain;
    //transition: All 0.2s;
    opacity: 1;
    img {
      width: 148px;
      margin-top: -35px;
    }
    span {
      display: block;
      font-size: 12px;
      color: #ccdaef;
      width: 75px;
      margin: auto;
      text-align: left;
      i {
        transform: rotate(180deg);
        display: block;
        float: right;
        margin-top: 2px;
        color: #9da4ad;
        font-size: 14px;
      }
    }

    &.toSmall{
      animation: toHide 0.2s;
      animation-fill-mode: both;
    }
  }
  .small-home-link {
    cursor: pointer;
    opacity: 0;
    position: absolute;
    bottom: 48px;
    left: 50%;
    margin-left: -16px;
    background: url("../assets/components/nav/side_menu_fold.svg") 50% no-repeat;
    width: 32px;
    height: 32px;
    transition: All 0.2s;
    &.toShowBig {
      animation: toShow 0.2s;
      animation-fill-mode: both;
    }
  }
}

</style>
